package com.edu.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.entity.shopDingdong;
import com.edu.service.UserBackgroundService;
import com.edu.service.impl.UserBackgroundServiceImpl;

/**
 * Servlet implementation class addShopServlet
 */
@WebServlet("/addShopServlet")
public class addShopServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addShopServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");

		String shopName = request.getParameter("shopName");
		String shopUrl = request.getParameter("shopUrl");
		String shopPrice = request.getParameter("shopPrice");
		String shopType = request.getParameter("shopType");
		

		double sprice = Double.parseDouble(shopPrice);
		
		shopDingdong shop=new shopDingdong(shopUrl, shopName, sprice,shopType);
		UserBackgroundService userBackService = new UserBackgroundServiceImpl();
		userBackService.addShop(shop);
		request.getRequestDispatcher("FenYeShopServlet").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
